<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import=" java.util.List"%>
<%@ page import=" java.text.DecimalFormat"%>
<%@ page import=" com.demo.entity.CartInfoList"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>我的购物车</title>
</head>
<body>
<center>
    <fieldset>
        <legend style="color: #00f"> <h3>我的购物车</h3></legend>
        <table >
            <tr>
                <th style="width: 180px">商品名</th>
                <th style="width: 80px">价格</th>
                <th style="width: 60px">数量</th>
                <th style="width: 80px">小计</th>
                <th style="width: 80px">是否修改</th>
                <th style="width: 80px">是否删除</th>
            </tr>
            <%
                double priceSum = 0;
                DecimalFormat df = new DecimalFormat("#.00");
                List<CartInfoList> cartInfo = (ArrayList<CartInfoList>) session.getAttribute("cartInfoList");
                for (CartInfoList cartInfoList : cartInfo) {
            %>
            <tr>          
                <th><%=cartInfoList.getP_name()%></th>
                <th><%=cartInfoList.getP_price()%></th>
                <th > <%=cartInfoList.getP_buynum()%></th>
                
                <th><%=df.format(cartInfoList.getP_price()*cartInfoList.getP_buynum())%></th>
                <%priceSum= priceSum+(cartInfoList.getP_price()*cartInfoList.getP_buynum());%>
                <th><a href="/WebStoreSSM/controller/changeCartInfoByProductsName/<%=cartInfoList.getP_name()%>">前往修改</a></th>
                <th><a href="/WebStoreSSM/controller/deleteCartInfoByProductsName/<%=cartInfoList.getP_name()%>">删除</a></th>
            </tr>
            <%
                }
            %>
            <tr><th colspan="5" style="text-align: right;">总计：<%=df.format(priceSum) %></th></tr>
            <tr><th><a href="/WebStoreSSM/controller/product_list_page_action">返回继续购物</a></th></tr>
        </table>
    </fieldset>
</center>
</body>
</html>